Repository navigation
feat(web): store draft and stashed attachments in IndexedDB - #1094
Merged
Merged
Conversation
Draft attachments and stashed prompts previously saved raw files as base64 data URLs inside localStorage, which shares a ~5 MB per-origin quota across the app and enforced a 3.5 MB draft cutoff and 2.7 MB stash budget. Large screenshots and device recordings hit those limits and showed a warning saying the attachment may be lost "on navigation". Move both composer draft attachments and prompt stash attachments to binary Blob storage in IndexedDB while keeping only lightweight metadata in localStorage: - Store draft and stash blobs under separate owner keys with a serialized mutation queue, explicit cleanup on remove, clear, send, restore, delete, and eviction, plus a startup orphan sweep with a 10-minute grace period. - Hydrate IndexedDB-backed draft attachments asynchronously on reload without dirtying cross-tab write tracking, wait for pending hydration or stash restore before sending or stashing, preserve metadata with a removable tile on transient read errors, and count hydrating files against the 8-attachment limit. - Migrate existing inline dataUrl drafts and stashed prompts into IndexedDB on startup, keep working inline copies intact if IndexedDB fails, and retire legacy t3code:composer-drafts:v1 keys once compacted. - Remove the 3.5 MB draft cutoff, the 2.7 MB stash budget, and lossy stash image recompression. - Verify draft attachment persistence structurally for the active thread instead of strict-decoding unrelated drafts, merge prompt stash writes against the latest stored queue across tabs, and update the unsaved attachment tooltip to say "may be lost on reload."
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Move IndexedDB draft hydration, legacy dataUrl migration, orphan cleanup, and async stash/restore orchestration behind dynamic imports so startup bundles stay within the web gzip budget.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft attachments and stashed prompts previously saved raw files as base64 data URLs inside
localStorage, which shares a ~5 MB per-origin quota across the app and enforced a 3.5 MB draft cutoff and 2.7 MB stash budget. Large screenshots (such as macOS Retina PNGs) and device recordings hit those limits and showed a warning saying the attachment may be lost "on navigation".This change moves both composer draft attachments and prompt stash attachments to binary
Blobstorage in IndexedDB (threadlines-draft-attachments) while keeping only lightweight metadata inlocalStorage:Blobbytes under separatedraft:<id>andstash:<entryId>:<id>keys with a serialized mutation queue, explicit deletion on remove/clear/send/restore/delete/eviction, and a startup orphan sweep with a 10-minute grace period.dataUrldrafts and stashed prompts, migrates their bytes into IndexedDB on startup without dropping working inline copies if IndexedDB fails, and retires legacyt3code:composer-drafts:v1keys once compacted.stashImageCompression.ts). Checks saved attachment IDs structurally per thread instead of strict-decoding unrelated drafts, merges prompt stash writes across tabs, and updates the unsaved attachment tooltip to say "may be lost on reload."Verification
vp fmtvp lintvp run typecheckvp run --cache '@threadlines/web#test' composerDraftStore promptStashStore(107 tests)vp run --cache '@threadlines/web#test:browser'(118 files, 1,222 tests)